package com.followmeandroid.tests;

import android.test.InstrumentationTestCase;

import com.followmeandroid.enums.PrintFriend;
import com.followmeandroid.models.Friend;
import com.followmeandroid.models.Location;
import com.followmeandroid.models.Member;

import java.util.List;
import java.util.UUID;

/**
 * Created by Nicholas on 12/4/2014.
 */
public class ModelTesting extends InstrumentationTestCase {

    Member member = new Member(new UUID(1234,1234),"Person","");
    Friend friend1 = new Friend(new UUID(111,111),"friend@email.com", new Location());

    public void test_Member_addFriend_With_Friend_Not_Already_Added() throws Exception {
        boolean value = member.addFriend(friend1);
        List<Friend> testList = member.getFriends();
        assertTrue("Friend was not added",testList.contains(friend1));
        assertTrue("Friend was not added",value);
    }

    public void test_Member_addFriend_With_Friend_Already_Added() throws Exception {
        assertTrue(member.addFriend(friend1));
        assertFalse("Friend was not previously added",member.addFriend(friend1));
    }

    public void test_Member_deleteFriend_With_Friend_Not_Yet_Removed() throws Exception {
        List<Friend> testList = member.getFriends();
        assertTrue(member.addFriend(friend1));
        assertTrue("Friend wasn't added", testList.contains(friend1));
        assertTrue(member.deleteFriend(friend1));
        testList = member.getFriends();
        assertFalse("Friend wasn't deleted", testList.contains(friend1));
    }

    public void test_Member_deleteFriend_With_Friend_Not_In_List() throws Exception{
        List<Friend> testList = member.getFriends();
        assertFalse(testList.contains(friend1));
        assertFalse(member.deleteFriend(friend1));
    }

    public void test_Member_isFriendsWith_With_No_Friend() throws Exception {
        assertFalse("Was already Friends", member.isFriendsWith(friend1));
    }

    public void test_Member_isFriendsWith_With_Friend_Existing() throws Exception {
        member.addFriend(friend1);
        assertTrue("Was not friend", member.isFriendsWith(friend1));
    }

    public void test_Friend_toString_set_as_EMAIL() throws Exception {
        String value = "";
        String wrongValue = "user@email.com";
        assertTrue(friend1.toString().equalsIgnoreCase(value));
        assertFalse(friend1.toString().equalsIgnoreCase(wrongValue));
    }

    public void test_Friend_toString_set_as_USERNAME() throws Exception {
        friend1.setPrint(PrintFriend.UNSERNAME);
        String value = "friend@email.com";
        String wrongValue = "user@email.com";
        assertTrue(friend1.toString().equalsIgnoreCase(value));
        assertFalse(friend1.toString().equalsIgnoreCase(wrongValue));
    }

    public void test_Friend_toString_set_as_FIRSTNAME() throws Exception {
        friend1.setPrint(PrintFriend.FIRSTNAME);
        String value = "";
        String wrongValue = "Name";
        assertTrue(friend1.toString().equalsIgnoreCase(value));
        assertFalse(friend1.toString().equalsIgnoreCase(wrongValue));
    }

    public void test_Friend_toString_set_as_NAME() throws Exception {
        friend1.setPrint(PrintFriend.NAME);
        String value = "  ";
        String wrongValue = "NotThe Person";
        assertTrue(friend1.toString().equalsIgnoreCase(value));
        assertFalse(friend1.toString().equalsIgnoreCase(wrongValue));
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

}